package com.neuedu.his.controller;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neuedu.his.po.Medicalrecord;
import com.neuedu.his.service.MedicalrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/api/medicalrecord")
public class MedicalRecordController {

    @Autowired
    private MedicalrecordService service;

    @TableId(type = IdType.AUTO)
    @TableField(value = "ID")
    private Integer id;   // i_d

    @TableField(value = "RegistID")
    private Integer registerId;     // UserName    user_name   驼峰

    @TableField(value = "Readme")
    private String readme;

    @TableField(value = "Present")
    private String present;

    @TableField(value = "PresentTreat")
    private String presentTreat;

    @TableField(value = "History")
    private String history;

    @TableField(value = "Allergy")
    private String allergy;

    @TableField(value = "Physique")
    private String physique;

    @TableField(value = "Diagnosis")
    private String diagnosis;

    @TableField(value = "Proposal")
    private String proposal;

    @TableField(value = "RegistLeID")
    private String careful;

    @TableField(value = "CaseNumber")
    private Integer casenumber;

    @TableField(value = "Proposal")
    private String Proposal;

    @TableField(value = "CheckResult")
    private String CheckResult;

    @TableField(value = "Handling")
    private String Handling;

    @Override
    public String toString() {
        return "MedicalRecordController{" +
                "id=" + id +
                ", registerId=" + registerId +
                ", readme='" + readme + '\'' +
                ", present='" + present + '\'' +
                ", presentTreat='" + presentTreat + '\'' +
                ", history='" + history + '\'' +
                ", allergy='" + allergy + '\'' +
                ", physique='" + physique + '\'' +
                ", diagnosis='" + diagnosis + '\'' +
                ", proposal='" + proposal + '\'' +
                ", careful='" + careful + '\'' +
                ", casenumber=" + casenumber +
                ", Proposal='" + Proposal + '\'' +
                ", CheckResult='" + CheckResult + '\'' +
                ", Handling='" + Handling + '\'' +
                '}';
    }

    @GetMapping("/getByCaseNumber")
    public List<Medicalrecord> getByCaseNumber(@RequestParam("casenumber") Integer casenumber) {  // 方法名也修改
        System.out.println("getByCaseNumber   casenumber="+casenumber);
        QueryWrapper<Medicalrecord> qw = new QueryWrapper<>();
        qw.eq("casenumber", casenumber);
        System.out.println(qw);
        return service.list(qw);
    }

}



